﻿@model RH.Web.ViewModels.ServicePeriodViewModel
@using RH.Web.Utility;
@using RH.Web.ViewModels;
@using RH.Common.Extensions;

@{
    Layout = "~/Views/Shared/_PopupLayout.cshtml";
	String pageTitle = "Edit Service Period";
    if (Model != null && Model.ID == 0)
    {             
        pageTitle = "Add New Service Period";
    }
    ViewBag.Title = Html.GetPageTitle(pageTitle);
	//ViewData[AppConstants.ViewDataKeys.SELECTED_MENU] = CompanyMenu.Dashboard;
    bool _HasSaved = RH.Common.DB.NullHandler.GetBoolean(ViewData[AppConstants.ViewDataKeys.SAVED]);
    
}

<div class="rh-page-heading">
    <h1>@pageTitle</h1>
    <div>Enter necessary information and then click the Save button.</div>
</div>
<div class="rh-page-content">
@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

	if (Model == null)
    {
        @: @Html.WarningMessageBox("Sorry! Requested Service Period was not found for edit.")
    }
	else
	{
		if (_HasSaved) {
            @Html.SuccessMessageBox("Congratulations! The Service Period saved successfully.")
        }
        else if (ViewData[AppConstants.ViewDataKeys.SAVED] != null && !_HasSaved)
        {
            @Html.WarningMessageBox("Sorry! we could not save the Service Period.")
        }
        @Html.ValidationMessage("DuplicateServicePeriod")
		@Html.HiddenFor(model => model.ID)

		@*<div class="editor-label">
			@Html.LabelFor(model => model.CompanyID)
		</div>
		<div class="editor-field">
			@Html.TextBoxFor(model => model.CompanyID)
			@Html.ValidationMessageFor(model => model.CompanyID)
		</div>*@
        @Html.HiddenFor(model => model.CompanyID)
		<div class="editor-label">
			@Html.LabelFor(model => model.StartDate)
		</div>
		<div class="editor-field">
			@Html.TextBoxFor(model => model.StartDate, new { @class = "datepicker" })
			@Html.ValidationMessageFor(model => model.StartDate)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.SpanDuration)
            <div class="rh-label-hint">Enter span duration in numeric values. For example if you want every span for one month then enter 30</div>
		</div>
		<div class="editor-field">
			@Html.TextBoxFor(model => model.SpanDuration)
			@Html.ValidationMessageFor(model => model.SpanDuration)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.TotalSpan)
		</div>
		<div class="editor-field">
			@Html.TextBoxFor(model => model.TotalSpan)
			@Html.ValidationMessageFor(model => model.TotalSpan)
		</div>
        <div class="editor-label">
            @Html.LabelFor(model => model.LeadPerSpan)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.LeadPerSpan)
            @Html.ValidationMessageFor(model => model.LeadPerSpan)
        </div>
		@*<div class="editor-label">
			@Html.LabelFor(model => model.IsActive)
		</div>
		<div class="editor-field">
			@Html.TextBoxFor(model => model.IsActive)
			@Html.ValidationMessageFor(model => model.IsActive)
		</div>*@
        @Html.HiddenFor(model => model.IsActive)
		@Html.HiddenFor(model => model.CreatedOn)
		<div class="rh-button-container">			
			<button type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-floppy-disk"></i> Save</button>
            @*<a href="@Url.AdminUrl("List", "ServicePeriod")" class="btn btn-default"><i class="glyphicon glyphicon-arrow-left"></i> Back to List</a>*@
		</div>		
	}
}
</div>
@section PageHeadSection{
    @Styles.Render(Bundles.jQueryUIDatePickerCSS)
    <script language="javascript" type="text/javascript">
        $(document).ready(function () { $('form').submit(function () { if($(this).valid()) ShowLoadingAnimation(false); }) });
    </script>
}
@section JavaScriptPlaceHolder
{    
    @Scripts.Render(Bundles.jQueryValidate, Bundles.jQeuryUIJS)
    @Html.Partial("_DatePicker", "")
}


